package com.beici.vueblogapp.filter;


import com.beici.vueblogapp.utils.getURIUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Map;
import java.util.Set;
public class sensitiveWordFilter implements Filter {

    @Override
        public void doFilter(ServletRequest request, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
            //强转成httpServlet
            request = (HttpServletRequest) request;
            request.setCharacterEncoding("utf-8");
            String requestURI = ((HttpServletRequest) request).getServletPath();
            //处理后的每个uri
            String[] uri = getURIUtils.getURI(requestURI);

            //进行uri过滤
            String FilterUri = getURIUtils.URIFilter(uri[4]);

            //覆盖
            request.setAttribute("content",FilterUri);
            filterChain.doFilter(request,servletResponse);
    }

}
